<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8"  content="text/html"/>
    <meta http-equiv="x-ua-compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <link th:href="@{/bootstrap/css/bootstrap.min.css}" rel="stylesheet" />
    <link th:href="@{/bootstrap/css/bootstrap-theme.min.css}" rel="stylesheet" />
    <title>获取用户信息</title>
</head>
<body>
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3 class="panel-title">访问Model</h3>
    </div>
    <div class="panel-body">
        <span th:ext="${person.name}"></span>
    </div>
</div>
<div th:if="${ not #lists.isEmpty(persons)}">
    <div class="panel panel-primary">
        <div class="panel-title">列表</div>
    </div>
    <div class="panel-body">
        <ul class="list-group">
            <li class="list-group-item" th:each="p:${persons}">
                <span th:text="${p.name}"></span>
                <span th:text="${p.age}"></span>
                <button class="btn" th:onclick="|getPersonName('${p.name}')|">获取名字</button>
            </li>
        </ul>
    </div>

</div>
<script th:src="@{/js/jquery-3.2.1.min.js}" type="text/javascript"></script>
<script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>
<script th:inline="javascript" type="text/javascript">
    var person = [[${person}]];
    console.log(person.name+"/" + person.age);
    function getPersonName(name) {
      console.log(name);
    }
</script>
</body>
</html>